<script setup>

import {get} from '@/net'
import router from "@/router/index.js";
import {useStore} from "@/stores/index.js";
import {ElMessage} from "element-plus";

const store = useStore()
//退出登入操作
const logout = () => {
  get('/api/auth/logout',(message)=>{
      ElMessage.warning(message)
      // 退出登入后见保存的用户清空,不然路由守卫那边同步获取的还是有值的用户
      store.auth.user = null
      //回到主界面
      router.push('/')
  })
}

</script>

<template>
<!-- 登入系统后的首页 -->
  <div>
    欢迎{{store.auth.user}}进入后台管理系统
  </div>
  <div>
    <!--  绑定退出登入事件  -->
    <el-button  @click="logout" type="danger">退出登入</el-button>
  </div>
</template>


<style scoped>

</style>